import { createStore } from 'vuex'
import { defineStore } from 'pinia'
import { removeToken } from '../utils/token.js';

export default createStore({
  state:()=>({
    userInfo:{},
  }),
  getters: {
    Array:(state)=>state.userInfo,
    Boolean:(state)=>state.isCollapse
  },
  mutations: {
    setUserInfo(state, data) {
      state.userInfo = data;
    },
    logout(state){
      localStorage.clear();
      state.userInfo = {};
    },
  },
  actions: {
      setUserInfo(data) {
        this.userInfo=data;
      },
  },
  persist: {
    enabled: true,
    storage: localStorage,
    key: 'userInfo',
    path: ['userInfo']
  }
});